<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Bills</title>
    <script src="${pageContext.request.contextPath}/static/js/bills.js"></script>
    <link href="${pageContext.request.contextPath}/static/css/bills.css" rel="stylesheet">
</head>
<body>
    <div class="content-container">
        <h2 class="page-title">账单信息</h2>
        <table class="bill-table">
            <thead>
                <tr>
                    <th>账号</th>
                    <th>套餐资费</th>
                    <th>额外花费</th>
                    <th>总计</th>
                    <th>余额</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td>${user.phone}</td>
                    <td>
                        <c:choose>
                            <c:when test="${user.userpackage == 1}">
                                50元/月
                            </c:when>
                            <c:when test="${user.userpackage == 2}">
                               60元/月
                            </c:when>
                            <c:when test="${user.userpackage == 3}">
                               150元/月
                            </c:when>
                            <c:otherwise>
                                N/A
                            </c:otherwise>
                        </c:choose>
                    </td>
                    <td>
                        <div>短信：${user.extra_sms}元</div>
                        <div>通话：${user.extra_bill}元</div>
                        <div>流量：${user.extra_traffic}元</div>
                    </td>
                    <td>
                        <c:choose>
                            <c:when test="${user.userpackage == 1}">
                                <c:set var="totalTraffic" value="${50 + user.extra_sms+user.extra_bill+user.extra_traffic}" />
                                ${totalTraffic}元
                            </c:when>
                            <c:when test="${user.userpackage == 2}">
                                <c:set var="totalTraffic" value="${60 + user.extra_sms+user.extra_bill+user.extra_traffic}" />
                                ${totalTraffic}元
                            </c:when>
                            <c:when test="${user.userpackage == 3}">
                                <c:set var="totalTraffic" value="${150 + user.extra_sms+user.extra_bill+user.extra_traffic}" />
                                ${totalTraffic}元
                            </c:when>
                            <c:otherwise>
                                N/A
                            </c:otherwise>
                        </c:choose>
                    </td>
                    <td>¥${user.balance}</td>
                </tr>
            </tbody>
        </table>
        <div>
            <button onclick="window.location.href='${pageContext.request.contextPath}/downloadLog?id=${user.id}'" class="action-button download-link">下载账单</button>
            <button onclick="window.location.href='${pageContext.request.contextPath}/userPage'" class="action-button exit-btn">退出</button>
        </div>
    </div>
</body>
</html>